package com.taotao.controller;

import com.taotao.pojo.EasyUIResult;
import com.taotao.pojo.TaotaoResult;
import com.taotao.pojo.TbContent;
import com.taotao.pojo.TbItem;
import com.taotao.service.ContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by caiyinli on 2018/8/24.
 */
@Controller
@RequestMapping("/content")
public class ContentController {

    @Autowired
    private ContentService contentService;

    @RequestMapping("/query/list")
    @ResponseBody
    public EasyUIResult getItemList(Integer page, Integer rows,Long categoryId){
        if(page == null){
            page = 1;
        }
        if(rows == null){
            rows = 20;
        }
        EasyUIResult itemList = contentService.getContentList(page, rows,categoryId);
        return itemList;
    }

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult insertContent(TbContent content) throws Exception{
        TaotaoResult result = contentService.insertContent(content);
        return result;
    }
}
